package net.sourceforge.peers.gui;

import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

import net.sourceforge.peers.Logger;

public class RegistrationStateRegistering extends RegistrationState {

    public RegistrationStateRegistering(String id, Registration registration,
            Logger logger) {
        super(id, registration, logger);
    }

    @Override
    public void registerSuccessful() {
        registration.setState(registration.SUCCESS);
        JLabel label = registration.label;
        URL url = getClass().getResource("green.png");
        ImageIcon imageIcon = new ImageIcon(url);
        label.setIcon(imageIcon);
        label.setText("注册成功");
    }

    @Override
    public void registerFailed() {
        registration.setState(registration.FAILED);
        JLabel label = registration.label;
        URL url = getClass().getResource("red.png");
        logger.debug("image url: " + url);
        ImageIcon imageIcon = new ImageIcon(url);
        label.setIcon(imageIcon);
        label.setText("注册失败");
    }

}
